baseSM (Function) Class
Base factory for sound models
Item Index
Methods
(baseSM)
-
i_node -
i_inputs -
i_outputs
Creates a new "GraphNode" that can be connected in an audio graph just like a Web Audio API audioNode (). The GraphNode returned also provides the generic interface (play, stop, setParam) for control. Also provides methods the sound modeler uses to, for example, register parameters to expose to users.
Parameters:
-
i_nodeObjectshould be empty literal object {}
-
i_inputsAudioNode Arrayan array of audio nodes that can be use to connect to this GraphNode
-
i_outputsAudioNode Arrayan array of audio nodes that will be used to connect this GraphNode to other audio nodes or the audio destinations
Returns:
The object used as "the model" providing the interface for configuring and controling. All other methods in this module belong to this object.
getAboutText
()
String
Returns:
text descritption of model, hints, created with setAboutText
getNumParams
()
Number
Returns:
the number of paramters the model exposes
getParam
-
i_name -
i_prop
Get specified information about a parameter
Parameters:
-
i_nameStringthe name of the param you want info about
-
i_propStringon of ["name", "type", "val", "normval", "min" or "max"]
Returns:
the value of the property you requested
getParamNames
()
Array of Strings
Returns:
array of model parameter names
getParamNames
-
index
Parameters:
-
indexObjectindex of the parameter whose name you want
Returns:
the name of the parameter with the secified index
onPlay
-
i_time
Override this in your sound model
Parameters:
-
i_timeNumbertime to play (can be fed to Web Audio API nodes in your override)
onRelease
-
i_time
Override this in your sound model to send the model in to its release phase
Parameters:
-
i_timeNumbertime to release (can be fed to Web Audio API nodes in your override)
onStop
-
i_time
override this in your sound model (optional)
Parameters:
-
i_timeNumbertime to stop (can be fed to Web Audio API nodes)
play
-
i_time
Parameters:
-
i_timeNumberwhat time to play (recommended use: 0 or no argument; use schedule(t,func) to scheudle play in the future)
qClear
()
Clear the queue of all future events for this model.
registerChildParam
-
childModel -
childPname -
[parentPname=childPname]
Grabs a parameter from a child model, registers it on this model, and just reflects all calls to the child
Parameters:
-
childModelSoundModel -
childPnameStringname of the child parameter to expose
-
[parentPname=childPname]String optionalname to use for the parameter
registerParam
-
i_name -
i_type -
i_val -
i_f
Creates a parameter that will be used to control the model and provide information
Parameters:
-
i_nameStringname to expose to the world for this param
-
i_typeStringtype ["range", "URL"]
-
i_valStringinitial value
-
i_fStringfunction to execute when setParam(name, val) is called.
registerParam
-
name -
the -
with -
function
Register a param which will then be accessible through the interface functions: setParam, getParam, etc.
Parameters:
-
nameNumberthe String value used to refer to this parameters
-
theStringjsaSound type of the parameter (either "range" or "URL"), the latter of which would better be called a string parameter.
-
withObjectthree numberical properties: ("min", "max", and "val"), the minimumum, maximum, and default values of the parameter.
-
functionFunctionto execute when the parameter is set with setParam()
release
-
i_time
Parameters:
-
i_timeNumbertime to release (recommended use: 0 or no argument; use schedule(t,func) to scheudle releases in the future)
schedule
-
t -
{Function
schedule a function to run in the future (uses a queue and a single timer)
Parameters:
-
tNumbertime to execute
-
{FunctionObjectfunction to execute at time t
setAboutText
-
i_text
Parameters:
-
i_textStringtext descritption of model, hints, etc
setParam
-
i_name -
i_val
set the parameter using values using its own units in [min,max]
Parameters:
-
i_nameStringthe name of the param you want to set
-
i_valNumberthe value to set the parameter
setParamNorm
-
i_name -
i_val
Set the parameter using values in [0,1]
Parameters:
-
i_nameStringthe name of the param you want to set
-
i_valNumberthe value to set the parameter
startRecording
()
Start recording audio output from the model
stop
-
i_time
Stop the model from playing, disconnects it from output so it won't waste system resources anymore. Your onRelease() method should schedule or call stop when it is done
Parameters:
-
i_timeNumbertime to stop (recommended use: 0 or no argument; use schedule(t,func) to scheudle stops in the future)
stopRecording
()
Stop recording audio output from the model
testPName
-
i_ind
test a parameter number for existence
Parameters:
-
i_indNumberindex of parameter
Returns:
either the parmaeter name (if it exists) or undefined
